@extends('admin.layouts.app')
@section('content')

                        <!-- Page-Title -->
                        <div class="row">
                            <div class="col-sm-12">
                                <h4 class="page-title">平台管理</h4>
                                <ol class="breadcrumb">
                                    <li><a href="#">系统</a></li>
                                    <li><a href="{{url('zadmin/type')}}">品类管理</a></li>
                                    <li class="active">修改品类</li>
                                </ol>
                            </div>
                        </div>
                        
                        <div class="row">
                        	<div class="col-lg-12">
                        		<div class="card-box">
                            <h2 class="m-t-0 header-title">修改品类</h2>
                            <hr/>
                             
                              @include('admin.common.error')
                        			<div class="row">
			                        	<div class="col-md-6">
                                  <form class="form-horizontal" role="form" action="{{url('zadmin/banner/'.$data->id)}}" method="post">{{ method_field('PUT') }}

                                              <div class="form-group">
                                                  <label class="col-md-2 control-label">名称</label>
                                                  <div class="col-md-10">
                                                      <input type="text" class="form-control" name="name" required="" value="{{$data->name}}" >
                                                  </div>
                                              </div>
                                              <div class="form-group">
                                                  <label class="col-md-2 control-label">滚动图</label>
                                                  <div class="col-md-10">
                                                      <button type="button" class="upload btn btn-default" data-id="pic" id="pic">上传滚动图</button>
                                                  </div>
                                                  

                      <div class="pic_pic"></div>
                                              </div>
                                              <div class="form-group">
                                                  <label class="col-md-2 control-label">内容图</label>
                                                  <div class="col-md-10">
        <button type="button" class="upload btn btn-default " id="contents" data-id="contents">上传内容图</button>
                                                  </div>
                                                  

                      <div class="pic_contents"></div>
                                              </div>
                                              
<div id="container"></div>
                                              

                                              <div class="form-group text-center">
                                                  
                                                  <button type="submit" class="btn btn-info waves-effect waves-light">保存</button>
                                              </div>
                                              
                             <input type="hidden" name="pic" />
                             <input type="hidden" name="contents" />                  
                             {{csrf_field()}}
                                          </form>
                                </div>
			                        	
			                        </div>

                             
			                        
                        			
                        		</div>
                                
                            </div> <!-- end col -->

                            
                        </div>
@endsection
                        
                        
                        

                  
            


    
  @section('js')
  <script type="text/javascript" src="/js/plupload/plupload.full.min.js"></script>
  <script type="text/javascript">
  $('.upload').on('click',function(){
        var _this = $(this);
        var _id = _this.data('id');
        initUploader(_id);    
  });

 
  function initUploader(id) {
    console.info(id);
    var uploader1 = new plupload.Uploader({
      runtimes : 'html5,flash,silverlight,html4',
      browse_button : id, // you can pass an id...
      container: document.getElementById('container'), // ... or DOM Element itself
      url : '/upload.php',
      flash_swf_url : '../js/Moxie.swf',
      silverlight_xap_url : '../js/Moxie.xap',
              
      filters : {
                max_file_size : '10mb',
                mime_types: [
                  {title : "Image files", extensions : "jpg,gif,png"}
                  
                ]
      },

              
    });

    uploader1.bind('Init', function(up, params) {
        // $('#filelist_'+id).html("");
    });

    $('#'+id).click(function(e) {
        
        e.preventDefault();
    });

    uploader1.init();

    uploader1.bind('FilesAdded', function(up, files) {
        up.refresh();
        var temp_img_name = '';
        $.each(files, function(i, file) {
            // $('#filelist_'+id).append(
            //     '<div id="' + file.id + '">' +
            //     file.name + ' (' + plupload.formatSize(file.size) + ') ' +
            // '</div>');
            if(temp_img_name == ''){
            temp_img_name += file.name;
            } else {
            temp_img_name += ', ' + file.name;
            }

        });
       
        up.start();
        up.refresh(); // Reposition Flash/Silverlight
    });

    uploader1.bind('UploadProgress', function(up, file) {
        $('#' + file.id + " b").html(file.percent + "%");
    });

    uploader1.bind('Error', function(up, err) {
        $('#filelist_'+id).append("<div>Error: " + err.code +
            ", Message: " + err.message +
            (err.file ? ", File: " + err.file.name : "") +
            "</div>"
        );

        up.refresh(); // Reposition Flash/Silverlight
    });

    uploader1.bind('FileUploaded', function(up, file,info) {
        $('#' + file.id + " b").html("100%");
        var rs =  JSON.parse(info.response);
        if(rs.status){
          var str = '<img style="padding:5px" src="'+rs.data+'" width="100">';
          $('.pic_'+id).append(str);                                
          $('input[name="'+id+'"]').val(rs.data);        
        }
          
    });

  
  
  }
</script>
        
  @endsection
    
